package day08HomeWrok;

public class PolymorphicDemo {
    public static void main(String[] args) {
        Animal[] animals = new Animal[5];
        animals[0] = new Dog("小黑",8,"黑");
        animals[1] = new Dog("小白",3,"白");
        animals[2] = new Chick("小金",2,"金");
        animals[3] = new Chick("大金",5,"金");
        animals[4] = new Fish("小灰",1,"灰");
        for (int i = 0; i < animals.length ; i++) {
            animals[i].eat();
            animals[i].drink();

            if (animals[i] instanceof Dog){
                Dog dog =(Dog) animals[i];
                dog.lookHome();
            }
            if (animals[i] instanceof  Chick){
                Chick chick = (Chick) animals[i];
                chick.layegg();
            }
            if (animals[i] instanceof  Swim){
                Swim s = (Swim) animals[i];
                s.swim();
            }


        }



    }
}
